package jwanalytics.ejb.webhouse;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Transient;


/**
 * This table matches closely the "Clickstream fact table for individual page events" presented 
 * on chapter 14 of "Wiley - The Data Warehouse Toolkit - 2nd Edition". */
@Entity
@Table(name="page_fact")
@SequenceGenerator(name="c_page_fact_sequence", sequenceName="c_page_fact_sequence")
public class PageFact {
	
	public Long id;
	
	public Integer webServerDateKey;
	
	/** This is with precision minutes. */
	public Integer timeOfDayKey;
	
	/** Foreign key to page_dimension */
	public Long pageKey;
	
	/** Foreign key to session_dimension */
	public Long sessionKey;
	
	public Date serverTimeMilliseconds;
	
	/** Count of seconds person remained on this page, for that we need the server time with seconds precision transient field. */
	public Integer pageSeconds;
	
	@Id
 	@Column(name="id")
 	@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="c_page_fact_sequence")	
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}
	
 	@Column(name="web_server_date_key")	
	public Integer getWebServerDateKey() {
		return webServerDateKey;
	}

	public void setWebServerDateKey(Integer webServerDateKey) {
		this.webServerDateKey = webServerDateKey;
	}
	
 	@Column(name="time_of_day_key")		
	public Integer getTimeOfDayKey() {
		return timeOfDayKey;
	}

	public void setTimeOfDayKey(Integer timeOfDayKey) {
		this.timeOfDayKey = timeOfDayKey;
	}
	
 	@Column(name="page_key")			
	public Long getPageKey() {
		return pageKey;
	}
 	
	public void setPageKey(Long pageKey) {
		this.pageKey = pageKey;
	}
	
 	@Column(name="session_key")				
	public Long getSessionKey() {
		return sessionKey;
	}
 	
	public void setSessionKey(Long sessionKey) {
		this.sessionKey = sessionKey;
	}
	
 	@Column(name="page_seconds")					
	public Integer getPageSeconds() {
		return pageSeconds;
	}
 	
	public void setPageSeconds(Integer pageSeconds) {
		this.pageSeconds = pageSeconds;
	}
	
	@Transient
	public Date getServerTimeMilliseconds() {
		return serverTimeMilliseconds;
	}
	
	public void setServerTimeMilliseconds(Date serverTimeMilliseconds) {
		this.serverTimeMilliseconds = serverTimeMilliseconds;
	}
	
}
